package com.xzy.sms.web.system.utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.xzy.sms.web.domain.service.UserService;
import com.xzyframework.SpringContextHolder;

/**
 * 登录工具类
 * 
 * @author macong
 * @since 1.0
 * @version 2014-10-28 macong
 */
public class LoginUtils {
    
    /**
     * 日志对象
     */
    protected static Logger logger = LoggerFactory.getLogger(LoginUtils.class);
    
    /** 用户服务类 */
    private static UserService userService;
    
    /** SessionManager */
    private static DefaultWebSessionManager sessionManager;
    
    /** securityManager */
    private static DefaultWebSecurityManager securityManager;
    
    /**
     * @return userService
     */
    public static UserService getUserService() {
        if (userService == null) {
            userService = SpringContextHolder.getBean(UserService.class);
        }
        return userService;
    }
    
    /**
     * @return securityManager
     */
    public static DefaultWebSecurityManager getSecurityManager() {
        if (securityManager == null) {
            securityManager = SpringContextHolder.getBean(DefaultWebSecurityManager.class);
        }
        return securityManager;
    }
    
    /**
     * @return sessionManager
     */
    public static DefaultWebSessionManager getSessionManager() {
        if (sessionManager == null) {
            sessionManager = SpringContextHolder.getBean(DefaultWebSessionManager.class);
        }
        return sessionManager;
    }
    
    /**
     * 执行获取authCode后操作
     * 
     * @param request request
     * @param response response
     * @return 是否成功执行
     */
    public static boolean loginAfterAuth(HttpServletRequest request, HttpServletResponse response) {
        
        return false;
    }
}
